using NUnit.Framework;
using Tycho.Parser.Peg;

namespace Tycho.Parser.Tests.Peg {
    [TestFixture]
    public class SpecialKeywordProductionFactorySpecification {
        [Test]
        public void ShouldReturnPunctuationProductionThatIncrementsBracketDepth () {
            var factory = new SpecialKeywordProductionFactory ();

            IProduction p = factory.CreateIncrementingPunctuation ("[");

            ParseResult result = p.Parse ("[");
            Assert.That (result.Context.BracketDepth, Is.EqualTo (1));
        }

        [Test]
        public void ShouldReturnPunctuationProductionThatDecrementsBracketDepth () {
            var factory = new SpecialKeywordProductionFactory ();

            IProduction p = factory.CreateDecrementingPunctuation ("[");

            const string source = "[";
            ParseResult result = p.Parse (source.ToCharArray (), 0, new ParseContext () {BracketDepth = 1}, source, new ParseEnvironment (null));
            Assert.That (result.Context.BracketDepth, Is.EqualTo (0));
        }
    }
}